const webpackConfig = require('../../build/webpack.test.conf.js')

module.exports = function (config) {
    config.set({
      // to run in additional browsers:
      // 1. install corresponding karma launcher
      //    http://karma-runner.github.io/0.13/config/browsers.html
      // 2. add it to the `browsers` array below.
      //浏览器
      browsers: ['PhantomJS', 'PhantomJS_custom'],
      customLaunchers: {
        'PhantomJS_custom': {
          base: 'PhantomJS',
          options: {
            windowName: 'mu-window',
            settings: {
              webSecurityEnabled: false
            },
          },
          flags: ['--load-images=true'],
          debug: true
        }
      },
      phantomjsLauncher: {
        exitOnresourceError: true
      },
      //测试框架
      frameworks: ['mocha', 'sinon-chai'],
      //测试报告
      reporters: ['spec', 'coverage'],
      //测试入口文件
      files: [
        './index.js', 
        {pattern: '../../src/assets/images/*.gif', watched: false, included: false, served: true,  nocache: false}, 
        {pattern: '../../src/assets/images/*.png', watched: false, included: false, served: true,  nocache: false}
      ],
      proxies: {
        "../assets/images/": "../../src/assets/images/"
      },
      //预处理器karma-webpack
      preprocessors: {
        './index.js': ['webpack', 'sourcemap']
      },
      //webpack配置
      webpack: webpackConfig,
      //webpack中间件
      webpackMiddleware: {
        noInfo: true,
      },
      //测试覆盖率报告
      coverageReporter: {
        dir: './coverage',
        reporters: [
          { type: 'lcov', subdir: '.' },
          { type: 'text-summary' },
        ]
      },
    })
  }
